home *** CD-ROM | disk | FTP | other *** search
- unit uAddToPhonebook;
-
- {
- *******************************************************************************
- * Descriptions: Add Contact to Phonebook
- * $Source: /cvsroot/fma/fma/uAddToPhonebook.pas,v $
- * $Locker: $
- *
- * Todo:
- *
- * Change Log:
- * $Log: uAddToPhonebook.pas,v $
- * Revision 1.3.6.1 2004/09/08 20:21:19 lordlarry
- * Added Exception.Message to the Exception Details Log
- *
- * Revision 1.3 2004/07/07 08:10:46 z_stoichev
- * Common Wizard Image usage
- *
- * Revision 1.2 2004/06/30 15:28:26 z_stoichev
- * GUI improvements
- *
- * Revision 1.1 2004/06/30 14:05:20 z_stoichev
- * Initial checkin.
- *
- *
- }
-
- interface
-
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, StdCtrls, TntStdCtrls, ExtCtrls, uSyncPhonebook, VirtualTrees;
-
- type
- TfrmAddContact = class(TForm)
- Bevel1: TBevel;
- btnOk: TButton;
- btnCancel: TButton;
- Panel1: TPanel;
- Image1: TImage;
- Label4: TLabel;
- lbProductName: TLabel;
- Button3: TButton;
- Label1: TLabel;
- lblNumber: TLabel;
- edContact: TTntEdit;
- btnSelect: TButton;
- RadioButton1: TRadioButton;
- RadioButton2: TRadioButton;
- rgPhoneType: TRadioGroup;
- procedure btnSelectClick(Sender: TObject);
- procedure RadioButtonClick(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- procedure btnOkClick(Sender: TObject);
- private
- procedure Set_NewNumber(const Value: string);
- { Private declarations }
- public
- { Public declarations }
- function GetSelectedContactData: PContactData;
- property NewNumber: string write Set_NewNumber;
- end;
-
- var
- frmAddContact: TfrmAddContact;
-
- implementation
-
- uses uGetContact, Unit1;
-
- {$R *.dfm}
-
- procedure TfrmAddContact.btnSelectClick(Sender: TObject);
- begin
- with TfrmGetContact.Create(nil) do
- try
- SelContacts := edContact.Text;
- if ShowModal = mrOk then begin
- edContact.Text := SelContacts;
- edContact.SetFocus;
- end;
- finally
- Free;
- end;
- end;
-
- procedure TfrmAddContact.RadioButtonClick(Sender: TObject);
- begin
- edContact.Enabled := RadioButton2.Checked;
- if edContact.Enabled then
- edContact.Color := clWindow
- else
- edContact.Color := clBtnFace;
- rgPhoneType.Enabled := edContact.Enabled;
- btnSelect.Enabled := edContact.Enabled;
- end;
-
- procedure TfrmAddContact.FormCreate(Sender: TObject);
- begin
- {$IFNDEF VER150}
- Form1.ThemeManager1.CollectForms(Self);
- {$ENDIF}
- Image1.Picture.Assign(Form1.FmaWebUpdate1.Picture);
- lblNumber.Font.Style := lblNumber.Font.Style + [fsBold];
- end;
-
- procedure TfrmAddContact.btnOkClick(Sender: TObject);
- var
- contact: PContactData;
- Number: string;
- begin
- if RadioButton1.Checked then
- ModalResult := mrOk
- else begin
- contact := GetSelectedContactData;
- if contact = nil then begin
- ShowMessage('You have to select an existing contact first');
- Exit;
- end;
- if Assigned(contact) then begin
- case rgPhoneType.ItemIndex of
- 0: Number := contact^.cell;
- 1: Number := contact^.work;
- 2: Number := contact^.home;
- 3: Number := contact^.fax;
- 4: Number := contact^.other;
- end;
- if (Number = '') or (MessageDlg('This phone type position is already taken by "'+Number+'". Overwrite it?',
- mtConfirmation,[mbYes,mbNo],0) = mrYes) then
- ModalResult := mrOk;
- end;
- end;
- end;
-
- function TfrmAddContact.GetSelectedContactData: PContactData;
- var
- Node: PVirtualNode;
- begin
- Result := nil;
- if RadioButton2.Checked then
- if Form1.frmSyncPhonebook.FindContact(Form1.ExtractContact(edContact.Text),Node) then begin
- Result := Form1.frmSyncPhonebook.ListContacts.GetNodeData(Node);
- end;
- end;
-
- procedure TfrmAddContact.Set_NewNumber(const Value: string);
- begin
- lblNumber.Caption := Value;
- end;
-
- end.
-